<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>let和const</h2>
</body>
<script>
    
    //let和var都是变量的，区别通常有3点
    console.log('前count:',count)
    var count=1;
    var count=2;
    console.log('后count:',count)

    let index=1;
    
    console.log('前index:',index)
   
   // let index=2;
    console.log('后index:',index)

    /**
     * 全局作用域
     * 
     * 
     */

   /*
     var a1=10
    let a2=20

  
     function getName() {
         var a1=100
         a2=200
        console.log('1函数内访问a1:',a1)
        console.log('2函数内访问a2:',a2)
     }
     getName()

     console.log('3函数外访问a1:',a1)
        console.log('4函数外访问a2:',a2)

    */

    //块级作用域
    let str2='hello，北京你好'
    if(true) {
       let str='hello vue.js'
       console.log('内部:',str)
       console.log('内部:',str2)
    }
    

    //console.log('外部：',str)
    console.log('外部：',str2)

    for(let i=0;i<10;i++) {
       // console.log('内部：',i)
    }

    //console.log('外部：',i)


    //let和const区别
    let t1=10
    t1=20
    const t2=60
   // t2=100

   const obj={
       name:'alice',
       age:20
   }

   obj={name:'hanmeimei'}


 //  obj.name='jack'
   console.log(obj.name)
  //  console.log('t1:',t1)

</script>
</html>